dojo.provide("miaigo.model.sgf.values.ListValueHandler");

dojo.require("miaigo.model.sgf.values.ValueHandler");
dojo.require("miaigo.model.sgf.values.PointValueHandler");
dojo.require("miaigo.model.sgf.values.LineValueHandler");
dojo.require("miaigo.model.sgf.values.LabelValueHandler");

dojo.declare(
    "miaigo.model.sgf.values.ListValueHandler",
    [miaigo.model.sgf.values.ValueHandler],
    {
	_valueType: "List",

	// item value handler parse each value according to type of
	// item type
	_itemValueHandler: null,

	// item type can be one of the following:
	// Point, Line, Label
	constructor: function(createParam)
	{
	    if (createParam && createParam.itemType)
	    {
		switch(createParam.itemType)
		{
		case "Point":
		    this._itemValueHandler = new miaigo.model.sgf.values.PointValueHandler();
		    break;
		case "Line":
		    this._itemValueHandler = new miaigo.model.sgf.values.LineValueHandler();
		    break;
		case "Label":
		    this._itemValueHandler = new miaigo.model.sgf.values.LabelValueHandler();
		    break;
		default:
		    throw "Unknown Item Type for List: " + itemType;
		}
	    }
	    else
	    {
		throw "Calling constructor of miaigo.model.sgf.values.ListValueHandler, parameter required is {itemType: itemType}";
	    }
	},

	getItemType: function()
	{
	    return this._itemValueHandler.getValueType();
	},

	parseValue: function(/* Array */values)
	{
	    var parsedValue = [];

	    for (i in values)
	    {
		parsedValue.push(this._itemValueHandler.parseValue([values[i]]));
	    }

	    return parsedValue;
	}
    });